#include "stdafx.h"
#include "showpicture.h"
#include "ui_showpicture.h"

ShowPicture::ShowPicture(QWidget *parent)
	: QDialog(parent)
	, second(600)
{
	setWindowModality(Qt::ApplicationModal);
	setAttribute(Qt::WA_ShowModal, true);
	setWindowFlags(Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::Dialog);
	
	auto desktop = QApplication::primaryScreen();
	QRect screen = desktop->availableGeometry();

	ui = new Ui::ShowPicture();
	ui->setupUi(this);
	ui->lcdNumber->display(second);
	ui->pictureLabel->setPixmap(QPixmap(":/images/background.png").scaled(screen.size()));

	timer = new QTimer(this);
	connect(timer, SIGNAL(timeout()), this, SLOT(timerUpdate()));
	timer->start(1000);
}

ShowPicture::~ShowPicture()
{
	delete ui;
}

void ShowPicture::timerUpdate()
{
	if (second > 0)
	{
		--second;
		ui->lcdNumber->display(second);
	}
	else
	{
		this->close();
	}
}
